package com.chat.view;

import com.chat.Local;
import com.chat.common.User;
import com.chat.utils.MouseFollow;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import javax.swing.*;
import java.io.IOException;

public class HeadController {
    
    public Button confirm;
    public ToggleGroup head;
    public Button fanhui;
    public RadioButton girlbutton;
    public RadioButton boybutton;
    public RadioButton head3;
    public RadioButton head4;
    public RadioButton head5;
    public RadioButton head6;
    public RadioButton head7;
    public RadioButton head8;

    public void confirmOnAction(ActionEvent event) {
         if(boybutton.isSelected()==true)
            Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\男头像.png");
         else if(girlbutton.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\女头像.png");
         else if(head3.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\男头像2.png");
         else if(head4.isSelected()==true)
               Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\男头像3.png");
         else if(head5.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\男头像4.png");
         else if(head6.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\女头像2.png");
         else if(head7.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\女头像3.png");
         else if(head8.isSelected()==true)
             Local.user.setHeadpicture("D:\\charclient\\src\\main\\resources\\com\\chat\\view\\男头像5.png");

        JOptionPane.showMessageDialog(null, "修改成功");
        Stage stage=(Stage) boybutton.getScene().getWindow();
        stage.close();
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(getClass().getResource("usermessage.fxml"));
        Parent root = null;
        try {
            root = fxmlLoader.load();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Stage regitsterstage=new Stage();
        Scene scene = new Scene(root);
        regitsterstage.initStyle(StageStyle.TRANSPARENT);
        MouseFollow in = new MouseFollow(root, regitsterstage);
        regitsterstage.setScene(scene);
        regitsterstage.show();
    }

}
